<template>
	<view class="policy-info">
		<!-- <u-tabs :list="tabList"  :current="currentIndex" @change="change"></u-tabs> -->
		<!-- <view class="tabs">
			<view :class="['tabs-item',{'active':currentIndex==index}]" v-for="(item,index) in tabList" :key="index" @click="change(index)">
				{{item.name}}
			</view>
		</view> -->
		<view class="policy-info-contain">
			<view class="title">
				关联产品
			</view>
				<view class="policy-info-contain-item">
					<!-- <u-field v-model="form.firstAgentName" label="上级代理商名称" disabled /> -->
					<!-- <u-field v-model="form.firstAgentNo" label="上级代理商编号" disabled /> -->
					<u-field v-model="form.agentName" label="代理商名称" disabled />
					<u-field v-model="form.agentNo" label="代理商编号" disabled />
					<u-field v-model="form.policyName" label="产品政策名称" disabled />
					<!-- <u-field v-model="form.policyCode" label="产品政策编码" disabled /> -->
					<u-field v-model="form.addDate" label="开通时间" disabled />
				</view>
				
				<template >
					<view class="title">
						激活政策
					</view>
					<template v-if="form.activeShare">
						<view class="policy-info-contain-item">
							<template v-if="!isEdit1">
								<!-- <u-field v-model="form.activeShare.amount" label="奖励金额" disabled /> -->
								<u-field v-model="form.activeShare.shareAmount" label="分账金额" disabled />
							</template>
							<template v-else>
								<!-- <u-field v-model="activeShare.amount" label="奖励金额" disabled /> -->
								<u-field v-model="activeShare.shareAmount"
									:label="`分账金额(${activeShare.minShareAmount}-${activeShare.maxShareAmount})`" />
							</template>
						</view>
						<view class="footer" v-if="!isMyPolicy">
							<u-button hover-class="none" @click="cancel(1)" v-if="isEdit1">取消</u-button>
							<u-button hover-class="none" type="primary" @click="submitForm(1)">{{ isEdit1 ? "提交" : "修改" }}
							</u-button>
						</view>
					</template>
					<template v-else>
						<view>暂未配置</view>
					</template>
				</template>
				
				<template >
					<view class="title">
						达标政策
					</view>
					<template v-if="form.standardShare">
						<template v-if="!isEdit2">
							<block v-for="(standardItem, standardIndex) in form.standardShare" :key="secondKey('A',standardIndex)">
								<view v-if="standardItem.existShare == 1" class="policy-info-contain-item">
								<h4>达标{{ standardIndex + 1 }}</h4>
									<!-- <u-field v-model="standardItem.configure.amount" label="奖励金额" disabled /> -->
									<u-field v-model=" standardItem.configure.shareAmount" label="分账金额" disabled />
								</view>
							</block>
						</template>
						<template v-else>
							<block v-for="(standardItem, standardIndex) in form.standardShare" :key="standardIndex">
								<!-- <h4>达标{{ standardIndex + 1 }}</h4> -->
								<view class="policy-info-contain-item">
									<u-field v-model="standardItem.cond" label="达标等级" disabled />
									<template v-if="standardItem.existShare == 1">
										<!-- <u-field v-model="standardItem.configure.amount" label="奖励金额" disabled /> -->
										<u-field v-model="standardItem.configure.shareAmount"
											:label="`分账金额(${standardItem.configure.minShareAmount}-${standardItem.configure.maxShareAmount})`" />
									</template>
								</view>
							</block>
						</template>
						<view class="footer" v-if="!isMyPolicy">
							<u-button hover-class="none" @click="cancel(2)" v-if="isEdit2">取消</u-button>
							<u-button hover-class="none" type="primary" @click="submitForm(2)">{{ isEdit2 ? "提交" : "修改" }}
							</u-button>
						</view>
					</template>
					<template v-else>
						<view>暂未配置</view>
					</template>
				</template>
				
				<template >
					<view class="title">
						服务费返现
					</view>
					<template v-if="form.serviceFeeShare">
						<template v-if="!isEdit3">
							<block v-for="(serviceFeeItem, serviceFeeIndex) in form.serviceFeeShare"
								:key="secondKey('B',serviceFeeIndex)">
								<view class="policy-info-contain-item">
								<h4>服务费{{ serviceFeeIndex + 1 }}</h4>
									<u-field v-model="serviceFeeItem.amount" label="服务费金额" disabled />
									<u-field v-model="serviceFeeItem.shareAmount" label="分账金额" disabled />
								</view>
							</block>
						</template>
						<template v-else>
							<block v-for="(serviceFeeItem, serviceFeeIndex) in serviceFeeShare"
								:key="secondKey('b',serviceFeeIndex)">
								<!-- <h4>服务费{{ serviceFeeIndex + 1 }}</h4> -->
								<view class="policy-info-contain-item">
									<u-field v-model="serviceFeeItem.amount" label="服务费金额" disabled />
									<u-field v-model="serviceFeeItem.shareAmount"
										:label="`分账金额(${serviceFeeItem.minShareAmount}-${serviceFeeItem.maxShareAmount})`" />
								</view>
							</block>
						</template>
						<view class="footer" v-if="!isMyPolicy">
							<u-button hover-class="none" @click="cancel(3)" v-if="isEdit3">取消</u-button>
							<u-button hover-class="none" type="primary" @click="submitForm(3)">{{ isEdit3 ? "提交" : "修改" }}
							</u-button>
						</view>
					</template>
					<template v-else>
						<view>暂未配置</view>
					</template>
				</template>
				
				<template >
					<view class="title">
						通讯费
					</view>
					<template v-if="form.commFeeShare">
						<template v-if="!isEdit4">
							<block v-for="(commFeeItem, commFeeIndex) in form.commFeeShare" :key="secondKey('D',commFeeIndex)">
								<view class="policy-info-contain-item">
								<h4>通讯费{{ commFeeIndex + 1 }}</h4>
									<u-field v-model="commFeeItem.amount" label="通讯费金额" disabled />
									<u-field v-model="commFeeItem.shareAmount" label="分账金额" disabled />
								</view>
							</block>
						</template>
						<template v-else>
							<block v-for="(commFeeItem, commFeeIndex) in commFeeShare" :key="secondKey('C',commFeeIndex)">
								<view class="policy-info-contain-item">
									<u-field v-model="commFeeItem.amount" label="通讯费金额" disabled />
									<u-field v-model="commFeeItem.shareAmount"
										:label="`分账金额(${commFeeItem.minShareAmount}-${commFeeItem.maxShareAmount})`" />
								</view>
							</block>
						</template>
						<view class="footer" v-if="!isMyPolicy">
							<u-button hover-class="none" @click="cancel(4)" v-if="isEdit4">取消</u-button>
							<u-button hover-class="none" type="primary" @click="submitForm(4)">{{ isEdit4 ? "提交" : "修改" }}
							</u-button>
						</view>
					</template>
					<template v-else>
						<view>暂未配置</view>
					</template>
				</template>
				
				<template >
					<view class="title">
						结算成本
					</view>
					<template v-if="!isEdit5">
						<view class="policy-info-contain-item" v-for="(agentCostItem, agentCostIndex) in form.agentCostScope" :key="secondKey('D',agentCostIndex)">
							<h4>{{totalTypeFormat(agentCostItem.totalType) }}</h4>
							<view  v-if="agentCostItem.totalType == 1">
								<u-field v-model="agentCostRate.posCreditRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.posCreditAdd"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 2">
								<u-field v-model="agentCostRate.posDebitRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.posDebitAdd"
									:label="`笔数费(元)`" disabled />
								<u-field v-if="agentCostItem.existLimit == 1" v-model="agentCostRate.posDebitLimit"
									:label="`封顶手续费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 3">
								<u-field v-model="agentCostRate.ysfRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.ysfAdd" :label="`笔数费(元)`"
									disabled />
							</view>
							<!-- <view v-if="agentCostItem.totalType == 4">
								<u-field v-model="agentCostRate.scanfRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.scanfAdd"
									:label="`笔数费(元)`" disabled />
							</view> -->
							<view v-if="agentCostItem.totalType == 5">
								<u-field v-model="agentCostRate.vipCreditRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.vipCreditAdd"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 6">
								<u-field v-model="agentCostRate.vipDebitRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.vipDebitAdd"
									:label="`笔数费(元)`" disabled />
								<u-field v-if="agentCostItem.existLimit == 1" v-model="agentCostRate.vipDebitLimit"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 7">
								<u-field v-model="agentCostRate.qpayRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.qpayAdd"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 10">
								<u-field v-model="agentCostRate.jhPayRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhPayAdd"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 11">
								<u-field v-model="agentCostRate.jhptPayRate" :label="`费率(%)`" disabled />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhptPayAdd"
									:label="`笔数费(元)`" disabled />
							</view>
							<view  v-if="agentCostItem.totalType == 12">
								<u-field v-model="agentCostRate.zyPayRate" :label="`费率(%)`" disabled />
								<!-- <u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhptPayAdd"
									:label="`笔数费(元)`" disabled /> -->
							</view>
						</view>
					</template>
					<template v-else>
						<view class="policy-info-contain-item" v-for="(agentCostItem, agentCostIndex) in form.agentCostScope" :key="secondKey('d',agentCostIndex)">
							<h4>{{totalTypeFormat(agentCostItem.totalType) }}</h4>
							<view  v-if="agentCostItem.totalType == 1">
								<u-field v-model="agentCostRate.posCreditRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.posCreditAdd"
									:label="`笔数费(元)`" />
							</view>
							<view v-if="agentCostItem.totalType == 2">
								<u-field v-model="agentCostRate.posDebitRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.posDebitAdd"
									:label="`笔数费(元)`" />
								<u-field v-if="agentCostItem.existLimit == 1" v-model="agentCostRate.posDebitLimit"
									:label="`封顶手续费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 3">
								<u-field v-model="agentCostRate.ysfRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.ysfAdd"
									:label="`笔数费(元)`" />
							</view>
						<!-- 	<view v-if="agentCostItem.totalType == 4">
								<u-field v-model="agentCostRate.scanfRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.scanfAdd"
									:label="`笔数费(元)`" />
							</view> -->
							<view  v-if="agentCostItem.totalType == 5">
								<u-field v-model="agentCostRate.vipCreditRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.vipCreditAdd"
									:label="`笔数费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 6">
								<u-field v-model="agentCostRate.vipDebitRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.vipDebitAdd"
									:label="`笔数费(元)`" />
								<u-field v-if="agentCostItem.existLimit == 1" v-model="agentCostRate.vipDebitLimit"
									:label="`笔数费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 7">
								<u-field v-model="agentCostRate.qpayRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.qpayAdd"
									:label="`笔数费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 10">
								<u-field v-model="agentCostRate.jhPayRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhPayAdd"
									:label="`笔数费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 11">
								<u-field v-model="agentCostRate.jhptPayRate" :label="`费率(%)`" />
								<u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhptPayAdd"
									:label="`笔数费(元)`" />
							</view>
							<view  v-if="agentCostItem.totalType == 12">
								<u-field v-model="agentCostRate.zyPayRate" :label="`费率(%)`" />
								<!-- <u-field v-if="agentCostItem.existAdd == 1" v-model="agentCostRate.jhptPayAdd"
									:label="`笔数费(元)`" disabled /> -->
							</view>
						</view>
					</template>
					<view class="footer" v-if="!isMyPolicy">
						<u-button hover-class="none" @click="cancel(5)" v-if="isEdit5">取消</u-button>
						<u-button hover-class="none" type="primary" @click="submitForm(5)">{{ isEdit5 ? "提交" : "修改" }}
						</u-button>
					</view>
				</template>
				
				<template >
					<view class="title">
						费率范围
					</view>
					<template v-if="!isEdit6">
						<view class="policy-info-contain-item" >
							<h4>贷记卡</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.payCreditRateMin}-${form.agentFeeRangeLable.payCreditRateMax}/%)`"
									>
									<div style="text-align: right;">{{form.agentFeeRange.payCreditRateMin}}-{{form.agentFeeRange.payCreditRateMax}}</div>
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.payCreditWithdrawalFeeMin}-${form.agentFeeRangeLable.payCreditWithdrawalFeeMax}/元)`"
									>
									{{form.agentFeeRange.payCreditWithdrawalFeeMin}}-{{form.agentFeeRange.payCreditWithdrawalFeeMax}}
								</u-form-item>
							</template>
							<h4>汇收银扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.jhPayRateMin}-${form.agentFeeRangeLable.jhPayRateMax}/%)`"
									>
									{{form.agentFeeRange.jhPayRateMin}}-{{form.agentFeeRange.jhPayRateMax}}
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.jhPayWithdrawalFeeMin}-${form.agentFeeRangeLable.jhPayWithdrawalFeeMax}/元)`"
									>
									{{form.agentFeeRange.jhPayWithdrawalFeeMin}}-{{form.agentFeeRange.jhPayWithdrawalFeeMax}}
								</u-form-item>
							</template>
							<h4>聚收银扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.jhptPayRateMin}-${form.agentFeeRangeLable.jhptPayRateMax}/%)`"
									>
									{{form.agentFeeRange.jhptPayRateMin}}-{{form.agentFeeRange.jhptPayRateMax}}
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.jhptPayWithdrawalFeeMin}-${form.agentFeeRangeLable.jhptPayWithdrawalFeeMax}/元)`"
									>
									{{form.agentFeeRange.jhptPayWithdrawalFeeMin}}-{{form.agentFeeRange.jhptPayWithdrawalFeeMax}}
								</u-form-item>
							</template>
							<h4>一码聚扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.zyPayRateMin}-${form.agentFeeRangeLable.zyPayRateMax}/%)`"
									>
									{{form.agentFeeRange.zyPayRateMin}}-{{form.agentFeeRange.zyPayRateMax}}
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.zyPayWithdrawalFeeMin}-${form.agentFeeRangeLable.zyPayWithdrawalFeeMax}/元)`"
									>
									{{form.agentFeeRange.zyPayWithdrawalFeeMin}}-{{form.agentFeeRange.zyPayWithdrawalFeeMax}}
								</u-form-item>
							</template>
							<h4>提现费</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.additionalProMin}-${form.agentFeeRangeLable.additionalProMax}/元)`"
									>
									{{form.agentFeeRange.additionalProMin}}-{{form.agentFeeRange.additionalProMax}}
								</u-form-item>
							</template>
							<h4>代理商能否修改费率</h4>
							<template >
								<u-form-item class="form-item" label="关-开" label-width="300" required>
									<u-switch v-model="form.agentFeeRange.canModify" :disabled="true"></u-switch>
								</u-form-item>
							</template>	
						</view>
					</template>
					<template v-else>
						<view class="policy-info-contain-item" >
							<h4>贷记卡</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.payCreditRateMin}-${form.agentFeeRangeLable.payCreditRateMax}/%)`"
									>
									<u-input v-model="form.agentFeeRange.payCreditRateMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.payCreditRateMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.payCreditWithdrawalFeeMin}-${form.agentFeeRangeLable.payCreditWithdrawalFeeMax}/元)`"
									>
									<u-input v-model="form.agentFeeRange.payCreditWithdrawalFeeMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.payCreditWithdrawalFeeMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
							</template>
							<h4>汇收银扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.jhPayRateMin}-${form.agentFeeRangeLable.jhPayRateMax}/%)`"
									>
									<u-input v-model="form.agentFeeRange.jhPayRateMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.jhPayRateMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.jhPayWithdrawalFeeMin}-${form.agentFeeRangeLable.jhPayWithdrawalFeeMax}/元)`"
									>
									<u-input v-model="form.agentFeeRange.jhPayWithdrawalFeeMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.jhPayWithdrawalFeeMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
							</template>
							<h4>聚收银扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.jhptPayRateMin}-${form.agentFeeRangeLable.jhptPayRateMax}/%)`"
									>
									<u-input v-model="form.agentFeeRange.jhptPayRateMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.jhptPayRateMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.jhptPayWithdrawalFeeMin}-${form.agentFeeRangeLable.jhptPayWithdrawalFeeMax}/元)`"
									>
									<u-input v-model="form.agentFeeRange.jhptPayWithdrawalFeeMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.jhptPayWithdrawalFeeMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
							</template>
							<h4>一码聚扫码</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`费率(${form.agentFeeRangeLable.zyPayRateMin}-${form.agentFeeRangeLable.zyPayRateMax}/%)`"
									>
									<u-input v-model="form.agentFeeRange.zyPayRateMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.zyPayRateMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.zyPayWithdrawalFeeMin}-${form.agentFeeRangeLable.zyPayWithdrawalFeeMax}/元)`"
									>
									<u-input v-model="form.agentFeeRange.zyPayWithdrawalFeeMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.zyPayWithdrawalFeeMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
							</template>
							<h4>提现费</h4>
							<template >
								<u-form-item class="form-item" label-width="300" required
									:label="`提现费(${form.agentFeeRangeLable.additionalProMin}-${form.agentFeeRangeLable.additionalProMax}/元)`"
									>
									<u-input v-model="form.agentFeeRange.additionalProMin" input-align="right"
										placeholder="请输入" type="digit" />~
									<u-input v-model="form.agentFeeRange.additionalProMax" input-align="left"
										placeholder="请输入" type="digit" />
								</u-form-item>
							</template>
							<h4>代理商能否修改费率</h4>
							<template >
								<u-form-item class="form-item" label="关-开" label-width="300" required>
									<u-switch v-model="form.agentFeeRange.canModify"></u-switch>
								</u-form-item>
							</template>	
						</view>
						
					</template>
					<view class="footer" v-if="!isMyPolicy">
						<u-button hover-class="none" @click="cancel(6)" v-if="isEdit6">取消</u-button>
						<u-button hover-class="none" type="primary" @click="submitForm(6)">{{ isEdit5 ? "提交" : "修改" }}
						</u-button>
					</view>
				</template>
			</view>
		
	</view>
</template>

<script>
	import {
		myPolicyList,
		listDataUnderAgent,
		activeShareEdit,
		agentCostEdit,
		standardShareEdit,
		serviceFeeShareEdit,
		commFeeShareEdit,
		agentFeeRangeEdit
	} from "@/api/agent-open";
	export default {
		data() {
			return {
				queryParams: {
					pageNum: 1,
					pageSize: 10,
				},
				form: {
					agentFeeRange: {},
					agentFeeRangeLable: {}
				},
				tabList: [{
						name: "关联产品"
					},
					{
						name: "激活政策"
					},
					{
						name: "达标政策"
					},
					{
						name: "服务费返现"
					},
					{
						name: "通讯费"
					},
					{
						name: "结算成本"
					},
				],
				currentIndex: 0,
				totalTypeOptions: [{
						"dictLabel": "POS贷记卡",
						"dictValue": "1",
					},
					{
						"dictLabel": "POS借记卡",
						"dictValue": "2",
					},
					{
						"dictLabel": "云闪付",
						"dictValue": "3",
					},
					// {
					// 	"dictLabel": "扫码",
					// 	"dictValue": "4",
					// },
					{
						"dictLabel": "VIP贷记卡",
						"dictValue": "5",
					},
					{
						"dictLabel": "VIP借记卡",
						"dictValue": "6",
					},
					{
						"dictLabel": "快捷",
						"dictValue": "7",
					},
					{
						"dictLabel": "汇收银扫码",
						"dictValue": "10",
					},
					{
						"dictLabel": "聚收银扫码",
						"dictValue": "11",
					},
					{
						"dictLabel": "一码聚扫码",
						"dictValue": "12",
					}
				],
				activeShare: {},
				standardShare: [],
				serviceFeeShare: [],
				commFeeShare: [],
				agentCostRate: {},
				agentFeeRange: {},
				agentFeeRangeLable: {},
				isEdit: false,
				isMyPolicy: false,
				agentCostRateRule: [], //代理商结算成本必填信息
				isEdit1:false,
				isEdit2:false,
				isEdit3:false,
				isEdit4:false,
				isEdit5:false,
				isEdit6:false,
			}
		},
		onLoad(options) {
			this.queryParams.agentNo = options.agentNo;
			this.queryParams.policyCode = options.policyCode;
			this.isMyPolicy = options.type == 0 ? true : false; // type 0:自己 ，1直属
			this.handleUpdate();
		},
		methods: {
			change(index) {
				console.log({index})
				this.currentIndex = index;
				this.isEdit = false;
			},
			async handleUpdate(query) {
				let response;
				if (this.isMyPolicy) {
					response = await myPolicyList(this.queryParams)
				} else {
					response = await listDataUnderAgent(this.queryParams)
				}
				this.form = response.rows[0];
				this.activeShare = this.form.activeShare;
				this.standardShare = this.form.standardShare;
				this.serviceFeeShare = this.form.serviceFeeShare;
				this.commFeeShare = this.form.commFeeShare;
				this.agentCostRate = this.form.agentCostRate;
				this.agentFeeRange = this.form.agentFeeRange;
				const obj = Object.assign({}, this.form.agentCostRate)
				// this.agentCostRateRule = Object.getOwnPropertyNames(obj);
				const that = this;
				console.log("that.form.agentCostRate",that.form.agentCostRate)
				// 获取有值的key 
				Object.keys(that.form.agentCostRate).forEach((key)=> {
					if(that.form.agentCostRate[key]){
						that.agentCostRateRule.push(key);
					}
				})
			},
			// 代理商结算成本必填信 匹配
			agentCostRateRulesInfo(params) {
				let isHas = true;
				let message = "";
				//  没有值时错误信息
				const errorInfo = {
					posCreditRate: "请填写POS贷记卡费率",
					posCreditAdd: "请填写POS贷记卡笔数费",
					posDebitRate: "请填写POS借记卡费率",
					posDebitAdd: "请填写POS借记卡笔数费",
					posDebitLimit: "请填写POS借记卡封顶手续费",
					vipCreditRate: "请填写VIP贷记卡费率",
					vipCreditAdd: "请填写VIP贷记卡笔数费",
					vipDebitRate: "请填写VIP借记卡费率",
					vipDebitAdd: "请填写VIP借记卡笔数费",
					vipDebitLimit: "请填写VIP借记卡封顶手续费",
					ysfRate: "请填写云闪付费率",
					ysfAdd: "请填写云闪付笔数费",
					scanfRate: "请填写扫码费率",
					scanfAdd: "请填写扫码笔数费",
					qpayRate: "请填写快捷支付费率",
					qpayAdd: "请填写快捷支付笔数费",
				};
				// 需要有的值
				const formCheckArray = [...this.agentCostRateRule];
				console.log({formCheckArray});
				// 查找没有值的返回改参数
				const result = formCheckArray.find((key) => !params[key]);
				if (result) { // 没有输入值时的提示判断
					message = errorInfo[result];
				}
				if (message) {
					this.$tip.toast(message)
					isHas = false;
				}
				return isHas;
			},
			// 修改提交
			async submitForm(index) {
				// const index = Number(this.currentIndex);
				let agentInfo = {
					agentNo: this.queryParams.agentNo,
					policyCode: this.queryParams.policyCode,
				};
				const editValue = `isEdit${index}`
				if (!this[editValue]) {
					return (this[editValue] = true);
				}
				let params = {};
				switch (index) {
					case 1:
						params = {
							...agentInfo,
							activeShare: {
								...this.activeShare
							}
						};
						break;
					case 2:
						params = {
							...agentInfo,
							standardShare: [...this.standardShare]
						};
						break;
					case 3:
						params = {
							...agentInfo,
							serviceFeeShare: [...this.serviceFeeShare]
						};
						break;
					case 4:
						params = {
							...agentInfo,
							commFeeShare: [...this.commFeeShare]
						};
						break;
					case 5:
						params = {
							...agentInfo,
							agentCostRate: {
								...this.agentCostRate
							}
						};
						break;
					case 6:
						params = {
							...agentInfo,
							agentFeeRange: {
								...this.agentFeeRange
							}
						};
						break;
					default:
						break;
				}
				// this.isEdit = false;
				let res;
				switch (index) {
					case 1: // 激活
						res = await activeShareEdit(params);
						break;
					case 2: // 达标
						res = await standardShareEdit(params);
						break;
					case 3: // 服务费
						res = await serviceFeeShareEdit(params);
						break;
					case 4: // 通讯费
						res = await commFeeShareEdit(params);
						break;
					case 5: // 结算成本
						let isHas = this.agentCostRateRulesInfo(params.agentCostRate);
						if (isHas) res = await agentCostEdit(params);
						break;
					case 6: // 费率范围
						let isFeeHas = this.agentFeeRangeRulesInfo(this.form.agentFeeRange);
						if (isFeeHas) res =   await agentFeeRangeEdit(this.form.agentFeeRange);
						break;	
				}
				if (!res) return;
				const {
					code,
					data,
					msg
				} = res;
				if (code === 200) {
					this.$tip.toast(msg)
					this.handleUpdate();
				}
				this[editValue] = false;

			},
			/** 取消按钮 **/
			cancel(index) {
				const value = `isEdit${index}`
				this[value] = false;
			},
			selectDictLabel(datas, value) {
				var actions = [];
				Object.keys(datas).map((key) => {
					if (datas[key].dictValue == ('' + value)) {
						actions.push(datas[key].dictLabel);
						return false;
					}
				})
				return actions.join('');
			},
			totalTypeFormat(row, column) {
				return this.selectDictLabel(this.totalTypeOptions, row);
			},
			secondKey(first, second){
			    return `${first}_${second}`  
			},
			// 代理商费率范围判断
			agentFeeRangeRulesInfo(params) {
				let isFeeHas = true;
				let message = "";
				
				if(this.form.agentFeeRange.payCreditRateMin.length<1){
					return this.$tip.toast('请输入贷记卡费率范围');
				}else{
					if(this.form.agentFeeRange.payCreditRateMin<this.form.agentFeeRangeLable.payCreditRateMin || this.form.agentFeeRange.payCreditRateMin>this.form.agentFeeRangeLable.payCreditRateMax){
						return this.$tip.toast('贷记卡费率范围：'+this.form.agentFeeRangeLable.payCreditRateMin+'-'+this.form.agentFeeRangeLable.payCreditRateMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.payCreditRateMax.length<1){
					return this.$tip.toast('请输入贷记卡费率范围');
				}else{
					if(this.form.agentFeeRange.payCreditRateMax<this.form.agentFeeRangeLable.payCreditRateMin || this.form.agentFeeRange.payCreditRateMax>this.form.agentFeeRangeLable.payCreditRateMax){
						return this.$tip.toast('贷记卡费率范围：'+this.form.agentFeeRangeLable.payCreditRateMin+'-'+this.form.agentFeeRangeLable.payCreditRateMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhPayRateMin.length<1){
					return this.$tip.toast('请输入汇收银扫码费率范围');
				}else{
					if(this.form.agentFeeRange.jhPayRateMin<this.form.agentFeeRangeLable.jhPayRateMin ||
						 this.form.agentFeeRange.jhPayRateMin>this.form.agentFeeRangeLable.jhPayRateMax){
						return this.$tip.toast('汇收银扫码费率范围：'+this.form.agentFeeRangeLable.jhPayRateMin+'-'+this.form.agentFeeRangeLable.jhPayRateMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhPayRateMax.length<1){
					return this.$tip.toast('请输入汇收银扫码费率范围');
				}else{
					if(this.form.agentFeeRange.jhPayRateMax<this.form.agentFeeRangeLable.jhPayRateMin ||
					 this.form.agentFeeRange.jhPayRateMax>this.form.agentFeeRangeLable.jhPayRateMax){
						return this.$tip.toast('汇收银扫码费率范围：'+this.form.agentFeeRangeLable.jhPayRateMin+'-'+this.form.agentFeeRangeLable.jhPayRateMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.jhptPayRateMin.length<1){
					return this.$tip.toast('请输入聚收银扫码费率范围');
				}else{
					if(this.form.agentFeeRange.jhptPayRateMin<this.form.agentFeeRangeLable.jhptPayRateMin ||
						 this.form.agentFeeRange.jhptPayRateMin>this.form.agentFeeRangeLable.jhptPayRateMax){
						return this.$tip.toast('聚收银扫码费率范围：'+this.form.agentFeeRangeLable.jhptPayRateMin+'-'+this.form.agentFeeRangeLable.jhptPayRateMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhptPayRateMax.length<1){
					return this.$tip.toast('请输入聚收银扫码费率范围');
				}else{
					if(this.form.agentFeeRange.jhptPayRateMax<this.form.agentFeeRangeLable.jhptPayRateMin ||
					 this.form.agentFeeRange.jhptPayRateMax>this.form.agentFeeRangeLable.jhptPayRateMax){
						return this.$tip.toast('聚收银扫码费率范围：'+this.form.agentFeeRangeLable.jhptPayRateMin+'-'+this.form.agentFeeRangeLable.jhptPayRateMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.zyPayRateMin.length<1){
					return this.$tip.toast('请输入一码聚扫码费率范围');
				}else{
					if(this.form.agentFeeRange.zyPayRateMin<this.form.agentFeeRangeLable.zyPayRateMin ||
						 this.form.agentFeeRange.zyPayRateMin>this.form.agentFeeRangeLable.zyPayRateMax){
						return this.$tip.toast('一码聚扫码费率范围：'+this.form.agentFeeRangeLable.zyPayRateMin+'-'+this.form.agentFeeRangeLable.zyPayRateMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.zyPayRateMax.length<1){
					return this.$tip.toast('请输入一码聚扫码费率范围');
				}else{
					if(this.form.agentFeeRange.zyPayRateMax<this.form.agentFeeRangeLable.zyPayRateMin ||
					 this.form.agentFeeRange.zyPayRateMax>this.form.agentFeeRangeLable.zyPayRateMax){
						return this.$tip.toast('一码聚扫码费率范围：'+this.form.agentFeeRangeLable.zyPayRateMin+'-'+this.form.agentFeeRangeLable.zyPayRateMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.additionalProMin.length<1){
					return this.$tip.toast('请输入提现费范围');
				}else{
					if(this.form.agentFeeRange.additionalProMin<this.form.agentFeeRangeLable.additionalProMin || this.form.agentFeeRange.additionalProMin>this.form.agentFeeRangeLable.additionalProMax){
						return this.$tip.toast('提现费范围：'+this.form.agentFeeRangeLable.additionalProMin+'-'+this.form.agentFeeRangeLable.additionalProMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.additionalProMax.length<1){
					return this.$tip.toast('请输入提现费范围');
				}else{
					if(this.form.agentFeeRange.additionalProMax<this.form.agentFeeRangeLable.additionalProMin || this.form.agentFeeRange.additionalProMax>this.form.agentFeeRangeLable.additionalProMax){
						return this.$tip.toast('提现费范围：'+this.form.agentFeeRangeLable.additionalProMin+'-'+this.form.agentFeeRangeLable.additionalProMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.payCreditWithdrawalFeeMin.length<1){
					return this.$tip.toast('请输入贷记卡提现费范围');
				}else{
					if(this.form.agentFeeRange.payCreditWithdrawalFeeMin<this.form.agentFeeRangeLable.payCreditWithdrawalFeeMin || this.form.agentFeeRange.payCreditWithdrawalFeeMin>this.form.agentFeeRangeLable.payCreditWithdrawalFeeMax){
						return this.$tip.toast('贷记卡提现费范围：'+this.form.agentFeeRangeLable.payCreditWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.payCreditWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.payCreditWithdrawalFeeMax.length<1){
					return this.$tip.toast('请输入贷记卡提现费范围');
				}else{
					if(this.form.agentFeeRange.payCreditWithdrawalFeeMax<this.form.agentFeeRangeLable.payCreditWithdrawalFeeMin || this.form.agentFeeRange.payCreditWithdrawalFeeMax>this.form.agentFeeRangeLable.payCreditWithdrawalFeeMax){
						return this.$tip.toast('贷记卡提现费范围：'+this.form.agentFeeRangeLable.payCreditWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.payCreditWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhPayWithdrawalFeeMin.length<1){
					return this.$tip.toast('请输入汇收银扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.jhPayWithdrawalFeeMin<this.form.agentFeeRangeLable.jhPayWithdrawalFeeMin || this.form.agentFeeRange.jhPayWithdrawalFeeMin>this.form.agentFeeRangeLable.jhPayWithdrawalFeeMax){
						return this.$tip.toast('汇收银扫码提现费范围：'+this.form.agentFeeRangeLable.jhPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.jhPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhPayWithdrawalFeeMax.length<1){
					return this.$tip.toast('请输入汇收银扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.jhPayWithdrawalFeeMax<this.form.agentFeeRangeLable.jhPayWithdrawalFeeMin || this.form.agentFeeRange.jhPayWithdrawalFeeMax>this.form.agentFeeRangeLable.jhPayWithdrawalFeeMax){
						return this.$tip.toast('汇收银扫码提现费范围：'+this.form.agentFeeRangeLable.jhPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.jhPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.jhptPayWithdrawalFeeMin.length<1){
					return this.$tip.toast('请输入聚收银扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.jhptPayWithdrawalFeeMin<this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMin || this.form.agentFeeRange.jhptPayWithdrawalFeeMin>this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMax){
						return this.$tip.toast('聚收银扫码提现费范围：'+this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.jhptPayWithdrawalFeeMax.length<1){
					return this.$tip.toast('请输入聚收银扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.jhptPayWithdrawalFeeMax<this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMin || this.form.agentFeeRange.jhptPayWithdrawalFeeMax>this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMax){
						return this.$tip.toast('聚收银扫码提现费范围：'+this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.jhptPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				
				if(this.form.agentFeeRange.zyPayWithdrawalFeeMin.length<1){
					return this.$tip.toast('请输入一码聚扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.zyPayWithdrawalFeeMin<this.form.agentFeeRangeLable.zyPayWithdrawalFeeMin || this.form.agentFeeRange.zyPayWithdrawalFeeMin>this.form.agentFeeRangeLable.zyPayWithdrawalFeeMax){
						return this.$tip.toast('一码聚扫码提现费范围：'+this.form.agentFeeRangeLable.zyPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.zyPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				if(this.form.agentFeeRange.zyPayWithdrawalFeeMax.length<1){
					return this.$tip.toast('请输入一码聚扫码提现费范围');
				}else{
					if(this.form.agentFeeRange.zyPayWithdrawalFeeMax<this.form.agentFeeRangeLable.zyPayWithdrawalFeeMin || this.form.agentFeeRange.zyPayWithdrawalFeeMax>this.form.agentFeeRangeLable.zyPayWithdrawalFeeMax){
						return this.$tip.toast('一码聚扫码提现费范围：'+this.form.agentFeeRangeLable.zyPayWithdrawalFeeMin+'-'+this.form.agentFeeRangeLable.zyPayWithdrawalFeeMax+'，请正确输入费率范围！');
					}
				}
				
				return isFeeHas;
			},
		}
	}
</script>

<style lang="scss">
	.policy-info-contain {
		margin: R(20);
		.title{
			font-weight: bold;
			font-size: R(30px);
			margin-top: R(60px);
			// color: #188dd5;
		}

		&-item {
			background-color: #FFFFFF;
			border-radius: R(10);
			padding: R(20);
			margin: R(20) 0;
		}

		.footer {
			display: flex;
			justify-content: space-around;
			margin: R(20) 0;

			button {
				width: R(120);
				height: R(60);
				line-height: R(70);
			}
		}
	}
	.tabs{
		display: flex;
		justify-content: space-between;
		align-items: center;
		text-align: center;
		flex-wrap: wrap;
		background-color: #FFFFFF;
		&-item{
		    height: R(70px);
			width: 30%;
			line-height: R(70px);
		}
		.active{
			background-color: #188dd5;
			color: #FFFFFF;
		}
	}

	/deep/ .u-label {
		flex: 0 0 R(250) !important;
		color: #8C8C8C;
	}

	/deep/ .u-border-bottom:after {
		border-bottom-width: 0px;
	}

	/deep/ .uni-input-input {
		text-align: right;
	}

	/deep/ .uni-input-input:disabled {
		color: #8C8C8C;
	}
</style>
